import com.ccBatis.io.Resources;
import com.ccBatis.sqlSession.SqlSession;
import com.ccBatis.sqlSession.SqlSessionFactory;
import com.ccBatis.sqlSession.SqlSessionFactoryBuilder;
import com.test.dao.UserDao;
import com.test.pojo.User;
import org.dom4j.DocumentException;
import org.junit.Test;

import java.io.InputStream;
import java.util.List;

public class CcbatisTest {


    @Test
    public void test() throws DocumentException {

        InputStream resourceAsStream = Resources.getResourceAsStream("sqlMapConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(resourceAsStream);

        SqlSession sqlSession = sqlSessionFactory.openSession();

        User user = new User();

        user.setUsername("zhangsan");
        user.setPassword("123");

        UserDao userDao = sqlSession.getMapper(UserDao.class);

        List<User> userList = userDao.findAll();

        System.out.println(userList);

        User byParams = userDao.findByParams(user);
        System.out.println(byParams);

        sqlSession.close();
    }
}
